<template>
  <!-- 点击用户头像时触发显示页面，“我的粉丝”菜单项显示内容 -->
  <div id="user-center-myFans-contrainer">
    <el-row id="user-center-myFans-contrainer-header">
      <span> 我的粉丝 </span>
      <span> 共{{total}}人 </span>
    </el-row>
    <el-row
      v-for="(fans, index) in fansList"
      :key="index"
      id="user-center-myFans-contrainer-main"
    >
      <el-divider />
      <el-avatar :size="64" :src="fans.avatar" />
      <span>
        {{ fans.nickName }}
      </span>
      <span>
        <el-button @click="removeDataById(fans.id)">移除粉丝</el-button>
      </span>
    </el-row>
    <el-pagination
      layout="prev, pager, next"
      :current-page="page"
      :page-size="limit"
      :total="total"
      @current-change="getPageList"
    ></el-pagination>
  </div>
</template>
<script>
import { queryFansList,delFans } from "@/api/article/MyFans";
export default {
  name: "MyFans",
  data() {
    return {
      fansList: {
        
      },
      page: 1, //当前页
      limit: 5, //每页记录数
      total: 0, //总记录数
    };
  },
  created() {
    this.getPageList();
  },
  methods: {
    getPageList(page = 1) {
      this.page = page;
      queryFansList(this.page, this.limit).then((response) => {
        this.fansList = response.data.data.records;
        this.total = response.data.data.total;
      });
    },
    removeDataById(id) {
      delFans(id).then((response) => {
        this.$message({
          type: "success",
          message: "移除粉丝成功!",
        });
        this.getPageList();
      });
    },
  },
};
</script>
<style>
#user-center-myFans-contrainer-main .el-avatar ~ span:last-of-type {
  float: right;
  margin-top: 1%;
}
#user-center-myFans-contrainer-main .el-avatar {
  vertical-align: middle;
}
#user-center-myFans-contrainer-header {
  height: 32px;
  line-height: 32px;
}
#user-center-myFans-contrainer-header span:first-of-type {
  font-size: 22px;
}
#user-center-myFans-contrainer-header span:last-of-type {
  float: right;
  font-size: 14px;
  color: #6b6c70;
}
</style>